"""
列表：[元素1，元素2，元素3.。。。]
列表推导：也叫列表包含
    提供了简单的创建列表的方式

语法结构：
    list = [ 表达式 for item in 序列]
    list = [表达式 for item in 序列 if 条件判断。。。]
    list = [表达式 (for  item in 序列 )(for item2 in 序列2 )(for  item in 序列3)....]
"""
list1 = [1, 2, 3, 4, 5, 6]

# list2 = [x for x in range(1, 7)]
# print(list2)
# print(type(list2))

list2 = [x for x in range(1, 7) if x % 2 == 1]
print(list2)
print(type(list2))

list3 = [x + y for x in range(1, 5) for y in range(5, 8)]
print(list3)

list4 = []
for x in range(1, 5):
    for y in range(5, 8):
        print(x + y, end=' ')
        list4.append(x + y)

print(list4)

# 范围 1- 5   的数的平方
list5 = [x ** 2 for x in range(1, 6)]
print(list5)

# 99 乘法表
list99 = [i * j for i in range(1, 10) for j in range(1, i + 1)]
print(list99)

for i in range(1, 10):
    for j in range(1, i + 1):
        print(i * j, end=' ')
